﻿<%@ Page Title="Xtablish CRM / Sales Pipeline" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="SalesPipeline.aspx.cs" Inherits="Web.SalesPipeline.SalesPipeline" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<asp:Content ID="Content1" ContentPlaceHolderID="headContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Con1" runat="server">
    <div class="register">
        <telerik:RadCodeBlock runat="server">
            <script type="text/javascript">
                function ddlStatus_SelectedIndexChanged(sender, eventArgs) {
                    var item = eventArgs.get_item();
                    var value = item.get_value();
                    if (value != "0")
                        document.getElementById('<%= divrbtnSelect.ClientID %>').style.display = "block";
                    else
                        document.getElementById('<%= divrbtnSelect.ClientID %>').style.display = "none";
                }
                function RowMouseOver(sender, eventArgs) {
                    index = eventArgs.get_itemIndexHierarchical();
                }
                function closeHandler(sender, args) {
                    //restore the overflow   
                    document.body.style.overflow = bodyOverflow;
                    document.documentElement.style.overflow = htmlOverflow;
                    sender.remove_close(closeHandler);

                }
                function OnClientClose(oWnd, args) {
                }
                function openRadwindow(url, formname) {
                    var grid = $find("<%= RadGrid1.ClientID %>");
                    var masterTableView = grid.get_masterTableView();
                    var row = masterTableView.get_dataItems()[index];
                    var contactID = row.getDataKeyValue("CONTACT_ID");
                    url += contactID;
                    openWin(url, formname);
                    return false;
                }
                function setSelectedIndex(combo) {
                    combo.trackChanges();
                    combo.get_items().getItem(0).select();
                    combo.updateClientState();
                    combo.commitChanges();
                }

                function ClearClick() {
                    setSelectedIndex($find("<%= ddlAssignedTo.ClientID %>"));
                    setSelectedIndex($find("<%= ddlStatus.ClientID %>"));
            }
            </script>
        </telerik:RadCodeBlock>
        <div class="container-fluid">
            <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
                <div class="row">
                    <div class="panel panel-default">
                        <div class="panel-heading" role="tab" id="headingOne">
                            <h4 class="panel-title">
                                <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">Search <i class="glyphicon glyphicon-circle-arrow-down" style="display: none;"></i><i class="glyphicon glyphicon-circle-arrow-up"></i>
                                </a>
                            </h4>
                        </div>
                        <div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
                            <div class="panel-body">
                                <div class="firstrow">
                                    <div class="edit-form">
                                        <div class="control-group" id="divAssignTo" runat="server">
                                            <div class="col-md-6 distance-control">
                                                <div class="col-md-4">
                                                    <label class="control-label">Assign To </label>
                                                </div>
                                                <div class="col-md-8">
                                                    <div class="controls">
                                                        <telerik:RadComboBox ID="ddlAssignedTo" runat="server" class="form-control"
                                                            Width="80%" Filter="StartsWith" MaxHeight="700px" />
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="clearfix"></div>
                                        </div>
                                        <div class="control-group">
                                            <div class="col-md-6 distance-control">
                                                <div class="col-md-4">
                                                    <label class="control-label">Status </label>
                                                </div>
                                                <div class="col-md-8">
                                                    <div class="controls">
                                                        <telerik:RadComboBox ID="ddlStatus" runat="server" class="form-control"
                                                            Width="80%" Filter="StartsWith" MaxHeight="700px" OnClientSelectedIndexChanged="ddlStatus_SelectedIndexChanged">
                                                            <Items>
                                                                <telerik:RadComboBoxItem Text="All" Value="0" />
                                                                <telerik:RadComboBoxItem Text="Appointment" Value="1" />
                                                                <telerik:RadComboBoxItem Text="Quotation Issue" Value="2" />
                                                                <telerik:RadComboBoxItem Text="Deposit Collected" Value="31" />
                                                                <telerik:RadComboBoxItem Text="Deposit Issue Invoice" Value="32" />
                                                                <telerik:RadComboBoxItem Text="Process Order" Value="4" />
                                                                <telerik:RadComboBoxItem Text="Payment Collection" Value="5" />
                                                            </Items>
                                                        </telerik:RadComboBox>
                                                    </div>
                                                    <div style="margin-top: 6px; display: none" id="divrbtnSelect" runat="server">
                                                        <telerik:RadButton ID="rbtnYes" Style="padding-left: 25px; padding-top: 0;" runat="server" ToggleType="Radio" ButtonType="ToggleButton" Text="Yes" Checked="true"
                                                            GroupName="Radios2" AutoPostBack="false" CausesValidation="false">
                                                        </telerik:RadButton>
                                                        <telerik:RadButton ID="rbtnNo" Style="padding-left: 25px; padding-top: 0;" runat="server" ToggleType="Radio" ButtonType="ToggleButton"
                                                            GroupName="Radios2" AutoPostBack="false" CausesValidation="false" Text="No">
                                                        </telerik:RadButton>
                                                        <telerik:RadButton ID="rbtnAll" Style="padding-left: 25px; padding-top: 0;" runat="server" ToggleType="Radio" ButtonType="ToggleButton"
                                                            GroupName="Radios2" AutoPostBack="false" CausesValidation="false" Text="All">
                                                        </telerik:RadButton>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="clearfix"></div>
                                        </div>
                                    </div>
                                    <div class="popup-btn">
                                        <div class="col-md-12 btn-edit">
                                            <button id="btnSearch" type="button" class="btn btn-defaul" runat="server" onserverclick="btnSearch_ServerClick">
                                                <img src="../Images/search.png" style="width: 20px; height: 20px" />
                                                Search
                                            </button>
                                            <button class="btn btn-defaul" type="button" onclick="ClearClick();return false;">
                                                <img src="../Images/clear.png" style="width: 20px; height: 20px" />
                                                Clear
                                            </button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="edit-form highlight">
                        <div class="col-md-12 combobox-email" style="padding-bottom: 5px">
                            <div class="col-md-5 btn-edit">
                            </div>
                            <div class="col-md-4" style="vertical-align: central; padding-top: 5px">
                                <label class="control-label" style="font-weight: 700">Email Template </label>
                            </div>
                            <div class="col-md-3" style="padding-right: 0">
                                <div class="controls">
                                    <telerik:RadComboBox ID="ddlEmailTemplate" runat="server" class="form-control" DataTextField="TEMPLATE_NAME" DataValueField="ID"
                                        Width="100%" Filter="StartsWith" MaxHeight="700px" />
                                </div>
                            </div>
                        </div>
                        <div class="clearfix"></div>
                        <div style="width: 100%">
                            <telerik:RadGrid ID="RadGrid1" ShowStatusBar="True" runat="server" AllowPaging="True" AllowSorting="True" AllowMultiRowSelection="True"
                                AutoGenerateColumns="False" GridLines="None" Width="100%" OnNeedDataSource="RadGrid1_NeedDataSource" OnPreRender="RadGrid1_PreRender"
                                OnItemCreated="RadGrid1_ItemCreated">
                                <ClientSettings EnableRowHoverStyle="true" EnablePostBackOnRowClick="false">
                                    <Selecting AllowRowSelect="false" />
                                    <ClientEvents OnRowMouseOver="RowMouseOver" />
                                </ClientSettings>
                                <MasterTableView PageSize="10" NoDetailRecordsText="No records" TableLayout="Fixed" NoMasterRecordsText="No records" ShowHeader="true" ClientDataKeyNames="CONTACT_ID" DataKeyNames="OrgID,STATUS_FINAL_STEP">
                                    <GroupByExpressions>
                                        <telerik:GridGroupByExpression>
                                            <GroupByFields>
                                                <telerik:GridGroupByField FieldName="STATUS_FINAL_STEP"></telerik:GridGroupByField>
                                            </GroupByFields>
                                            <SelectFields>
                                                <telerik:GridGroupByField FieldName="STATUS_FINAL_STEP"></telerik:GridGroupByField>
                                            </SelectFields>
                                        </telerik:GridGroupByExpression>
                                    </GroupByExpressions>
                                    <Columns>
                                        <telerik:GridBoundColumn DataField="CONTACT_NAME" HeaderText="Contact Name" UniqueName="CONTACT_NAME" SortExpression="CONTACT_NAME">
                                            <HeaderStyle Font-Bold="true" HorizontalAlign="center" Width="15%" />
                                             <ItemStyle Wrap="false" HorizontalAlign="center" Width="15%" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="STAGE" HeaderText="Stage" UniqueName="STAGE" SortExpression="STAGE">
                                            <HeaderStyle Font-Bold="true" HorizontalAlign="center" Width="5%" />
                                             <ItemStyle Wrap="false" HorizontalAlign="center" Width="5%" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="STATUS_NOTE" HeaderText="Notes" UniqueName="STATUS_NOTE" SortExpression="STATUS_NOTE">
                                            <HeaderStyle Font-Bold="true" HorizontalAlign="center" Width="20%" />
                                             <ItemStyle Wrap="false" HorizontalAlign="left" Width="20%" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridTemplateColumn DataField="PRIMARY_EMAIL" HeaderText="Email" UniqueName="PRIMARY_EMAIL" SortExpression="PRIMARY_EMAIL">
                                            <HeaderStyle Font-Bold="true" HorizontalAlign="center" Width="15%" />
                                             <ItemStyle Wrap="false" HorizontalAlign="left" Width="15%" />
                                            <ItemTemplate>
                                                <asp:LinkButton ID="lbtnSendEmail" runat="server" Text='<%# Eval("PRIMARY_EMAIL") %>' OnClick="sendEmail_Click" ForeColor="blue" />
                                            </ItemTemplate>
                                        </telerik:GridTemplateColumn>
                                        <telerik:GridBoundColumn DataField="ORGANIZATION_NAME" HeaderText="Company Name" UniqueName="ORGANIZATION_NAME" SortExpression="ORGANIZATION_NAME">
                                            <HeaderStyle Font-Bold="true" HorizontalAlign="center" Width="15%" />
                                             <ItemStyle Wrap="false" HorizontalAlign="center" Width="15%" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridHyperLinkColumn SortExpression="COMPANY_WEBSITE" DataTextFormatString="{0}"
                                            DataNavigateUrlFields="COMPANY_WEBSITE" UniqueName="COMPANY_WEBSITE" DataNavigateUrlFormatString="{0}"
                                            HeaderText="Company Website" DataTextField="COMPANY_WEBSITE" Target="_blank">
                                            <HeaderStyle Font-Bold="true" HorizontalAlign="center" Width="17%" />
                                             <ItemStyle Wrap="false" HorizontalAlign="left" Width="17%" CssClass="hyperlink" />
                                        </telerik:GridHyperLinkColumn>                                        
                                        <telerik:GridBoundColumn DataField="ASSIGN_TO" HeaderText="Assign To" UniqueName="ASSIGN_TO" SortExpression="ASSIGN_TO">
                                            <HeaderStyle Font-Bold="true" HorizontalAlign="center" Width="10%" />
                                             <ItemStyle Wrap="false" HorizontalAlign="center" Width="10%" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridTemplateColumn AllowFiltering="false" HeaderText="Tools" UniqueName="TOOLS">
                                            <HeaderStyle Font-Bold="true" HorizontalAlign="center" Width="10%" />
                                            <ItemStyle HorizontalAlign="center" Width="10%" />
                                            <ItemTemplate>
                                                <asp:LinkButton ID="lbtnEdit" runat="server" ToolTip="Edit" OnClientClick="return openRadwindow('EditSalesPipeline.aspx?ContactID=' ,'rwEditSalesPipeline');">
                                                        <image src="../Images/edit.png" style="width:18px;height:18px"/>
                                                </asp:LinkButton>
                                            </ItemTemplate>
                                        </telerik:GridTemplateColumn>
                                    </Columns>
                                    <PagerStyle PageSizes="5,10,20,50" PagerTextFormat="{4}<strong>{5}</strong> items matching your search criteria"
                                        PageSizeLabelText="Items per page:" AlwaysVisible="true" />
                                </MasterTableView>
                                <PagerStyle Mode="NumericPages"></PagerStyle>
                            </telerik:RadGrid>
                        </div>
                    </div>
                    <div class="clearfix"></div>
                </div>
            </div>
        </div>
    </div>
</asp:Content>
